import {
  reqGetBaseCategoryList,
  reqGetBannerListData,
  reqGetFloorsListData,
} from '@/api'
const state = {
  categoryList: [],
  bannerList: [],
  floorsList: [],
}
const actions = {
  //获取导航栏数据
  async getCategoryList({ commit }) {
    const result = await reqGetBaseCategoryList()
    if (result.code === 200) {
      commit('SAVE_CATEGORY_LIST', result)
    } else {
      console.log(result.message)
    }
  },
  //获取大轮播广告图数据
  async getBannerList({ commit }) {
    const result = await reqGetBannerListData()
    if (result.code === 200) {
      commit('SAVE_BANNER_LIST_DATA', result.data)
    } else {
      console.log(result.message)
    }
  },
  //获取floor组件的轮播图数据
  async getFloorsList({ commit }) {
    const result = await reqGetFloorsListData()
    commit('SAVE_FLOORS_LIST_DATA', result.data)
  },
}
const mutations = {
  SAVE_CATEGORY_LIST(state, payload) {
    state.categoryList = payload.data
  },
  SAVE_BANNER_LIST_DATA(state, bannerList) {
    state.bannerList = bannerList
  },
  SAVE_FLOORS_LIST_DATA(state, floorsList) {
    state.floorsList = floorsList
  },
}
const getters = {}

export default {
  namespaced: true,
  state,
  actions,
  mutations,
  getters,
}
